package com.symc.sims0213xfw.service.impl;

import com.symc.sims0213xfw.bean.StudentView;
import com.symc.sims0213xfw.dao.impl.StudentViewDaoImpl;
import com.symc.sims0213xfw.service.StudentService;
import com.symc.sims0213xfw.service.StudentViewService;

import java.util.List;

/**
 * @Author: 凤文  沈阳医学院2019级医学信息工程 0213
 * @CreateTime: 2022/01/22 20:32
 * @Description: 相关查询
 */
public class StudentViewServiceImpl implements StudentViewService {
    @Override
    public List<StudentView> getStudentViews() {
//        List<StudentView> studentViews =
//                new StudentViewDaoImpl().queryListStudentView();
//        List<StudentView> newStudentViews =
//                studentViews.stream().filter(studentView -> studentView.getIsVisible() == StudentService.VISIBLE).collect(Collectors.toList());
//        return newStudentViews;
        return new StudentViewDaoImpl().queryListVisibleStudentView();
    }

    @Override
    public StudentView getStudentView(String id) {
        StudentView studentView = new StudentViewDaoImpl().queryStudentView(id);
        if (studentView == null) {
            return null;
        }

        if (studentView.getIsVisible() == StudentService.VISIBLE) {
            return studentView;
        }
        return null;
    }

    public Integer getIsVisible(String id) {
        return getStudentView(id).getIsVisible();//0或1
    }
}
